  import {ref,onMounted,onUnmounted} from 'vue'
  export function getPostion(){
  // 点击获取鼠标位置的方法---------------------
  let x=ref(0);
  let y=ref(0);
  let getMouse=(event:any)=>{
      x.value=event.clientX;
      y.value=event.clientY;
  }
  onMounted(()=>{ //组件挂在后
      console.log("组件挂载后")
      document.addEventListener("click",getMouse)  
  })
  onUnmounted(()=>{ //组件卸载后
      console.log("卸载后")
    document.removeEventListener("click",getMouse)
  })
  return {x,y}
}
    // -----------------------------------